<!DOCTYPE html>
<html>

<head>
    <title>{$Think.config.app_name}</title>
    {include file="public/head_frame"/}
</head>

<body class="layui-layout-body">
    <div id="LAY_app" class="layadmin-tabspage-none">
        <div class="root_box" id="LAY_app_body" v-cloak>
            <form class="layui-form" action="" lay-filter="example">
                <div class="layui-form-item">
                    <div class="layui-form-item">
                        <label class="layui-form-label">手机</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入手机号" class="layui-input" v-model="item.user_account">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">昵称</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入昵称" class="layui-input" v-model="item.user_name">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入邮箱" class="layui-input" v-model="item.user_email">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">身份证</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入身份证" class="layui-input" v-model="item.user_idcard">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">真实姓名</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="请输入真实姓名" class="layui-input" v-model="item.user_truename">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">登录密码</label>
                        <div class="layui-input-block">
                            <input type="text" placeholder="不修改请留空" class="layui-input" v-model="item.user_password">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户组</label>
                        <div class="layui-input-block">
                            <select lay-ignore class="layui-input" name="user_group" v-model="item.user_group">
                                <option v-for="group in group_list" :value="group.group_id" :label="group.group_name">
                                </option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="button" class="layui-btn" @click="submit">立即提交</button>
                        </div>
                    </div>
            </form>
        </div>
    </div>
</body>
{include file="public/foot_frame"/}
<script>
    var app = new Vue({
        el: ".root_box",
        data: {
            item: {},
            group_list: [],
        },
        created: function () {
            var postData = PostCommon;
            $.post("/api/group/lists", postData, function (data, status) {
                _hideLoading();
                if (data.code != 200) {
                    _alert(data.msg);
                } else {
                    app.group_list = data.data.data;
                    app.item.user_group = app.group_list[0].group_id;
                }
            });

        },
        methods: {
            submit: function () {
                _loading();
                console.log(this.item);
                console.log(PostCommon);
                $.post("/api/user/add", Object.assign(this.item, PostCommon), function (data, status) {
                    _hideLoading();
                    console.log(data);
                    if (data.code != 200) {
                        if (data.url) {
                            location.replace(data.url);
                        }
                        _alert(data.msg);
                    } else {
                        parent.closewindow();
                    }
                });
            },
        }
    });
</script>

</html>